
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

    <!-- easyui -->
    <link rel="stylesheet" type="text/css" href="easyui/jquery-easyui-1.5/themes/gray/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/jquery-easyui-1.5/themes/icon.css"/>
    <script type="text/javascript" src="easyui/jquery-easyui-1.5/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery-easyui-1.5/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui/jquery-easyui-1.5/locale/easyui-lang-zh_CN.js"></script>

    <!-- easyui扩展 -->
    <link rel="stylesheet" type="text/css" href="easyui/easyui-ext/icons/icon-standard.css"/>
    <script type="text/javascript" src="easyui/easyui-ext/icons/icon-standard.js"></script>

    <!-- 自定义js -->
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/extJs.js"></script>

    <!-- 自定义css -->
    <link rel="stylesheet" href="css/common.css">

</head>
<body>
<div style="width:600px;margin:150px auto;">
<div class="easyui-panel" title="欢迎登录"
     style="width:500px;height:300px;padding:10px;text-align:center; overflow:hidden;"
     data-options="closable:false,collapsible:false,minimizable:false,maximizable:false">
    <form id="loginForm" method="post">
        <table style="margin:50px auto;">
            <input type="hidden" name="id">
            <tr>
                <td></td>
                <td><label>登录名:</label></td>
                <td><input class="easyui-textbox" type="text" id="username" name="username"
                           data-options="required:true,value:'admin'"/></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td><label>密&nbsp;码:</label></td>
                <td><input class="easyui-passwordbox" type="text" id="pass" name="pass"
                           data-options="required:true,value:'123'"/></td>
                <td></td>
            </tr>
            <tr style="height: 20px;"></tr>
            <tr>
                <td colspan="4" align="center">
                    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
                       onclick="javascript:btlogin()">登录</a>
                </td>
            </tr>
        </table>
    </form>
</div>
</div>
</body>
<script type="application/javascript">
    function btlogin(){
        //获取文本框值
        var username =$("#username").val();
        var pwd=$("#pass").val();
        //访问登录接口
        console.log(username);
        $.ajax({

            type: "POST",

            url: "/MyDemo/LoginDao.php",

            dataType:"json",
            data: { username: username, pwd: pwd },

            success: function (data) {

                if(data.code==200){
                    //200代表访问成功
                    console.log("------------------"+data);
                    if("登录成功"==data.message){
                        //登录成功，将数据传输到主页
                        window.location.href="show.php";
                        // alert(data.data);
                    }else{
                        alert(data.message);
                    }


                }else{
                    alert("访问失败，请稍后重试")
                }

            }

        });
    }

</script>
</html>